<%--
  Created by IntelliJ IDEA.
  User: lcc
  Date: 2021/11/15
  Time: 15:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/common.jsp"%>
<html>
<head>
    <title>Title</title>
    <script>
        $(function (){
            $('#tree').treeview({
                data: getTree(),
                //data : 包含当前节点的所有信息
                onNodeSelected: function (event,data){
                    $.addtabs.add({
                        title:data.text,
                        url : data.url,
                        id : data.id
                    })

                }
            });
        })


          function getTree() {
              var tree = "";
              $.ajax({
                  url : "<%=path%>/menu/getMenuInfo",
                  type : "get",
                  dataType : "json",
                  async : false,//要改成false,防止其他加载完这个还没加载完
                  success : function (result){
                      tree = result;
                  },
                  error : function (result){
                      console.log(result);
                  }
              })
              return tree;
          }

    </script>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
          <div class="col-md-3">
            <div id="tree"></div>
          </div>
            <div class="col-md-9">
                <!--addTabs 导航栏-->
                <ul class="nav nav-tabs" id="myTab"></ul>
                <!--addTabs 容器-->
                <div class="tab-content"></div>
            </div>
        </div>
    </div>
</body>
</html>
